/*
 * FloatDimension.java
 *
 * Created on November 6, 2007, 6:42 PM
 */
package com.kudo.util;

/**
 * A simple FloatDimension (width, height) for components.
 *
 * @author davedes
 * @since b2.0
 */
public class FloatDimension {

    /**
     * The width of this FloatFloatDimension.
     */
    public float width;
    /**
     * The height of this FloatFloatDimension.
     */
    public float height;

    /**
     * Creates a new instance of FloatDimension with the specified width and
     * height.
     *
     * @param width the width of this FloatFloatDimension
     * @param height the height of this FloatFloatDimension
     */
    public FloatDimension(float width, float height) {
        this.width = width;
        this.height = height;
    }

    /**
     * Creates a new instance of FloatDimension with a width and height of zero.
     */
    public FloatDimension() {
        this(0, 0);
    }

    /**
     * Creates a new instance of FloatDimension using the width and height of
     * the specified FloatDimension object.
     *
     * @param d a FloatFloatDimension
     */
    public FloatDimension(FloatDimension d) {
        this(d.width, d.height);
    }

    /**
     * Sets the size of this FloatDimension to the sepcified width and height.
     *
     * @param width the new width
     * @param height the new height
     */
    public void setSize(float width, float height) {
        this.width = width;
        this.height = height;
    }

    /**
     * Sets the size of this FloatFloatDimension to the size of the given
     * FloatFloatDimension object.
     *
     * @param d the FloatFloatDimension to use for the new width and height
     */
    public void setSize(FloatDimension d) {
        this.setSize(d.width, d.height);
    }

    /**
     * Returns <tt>true</tt> if the given Object is an instance of
     * FloatDimension with the same width and height as this
     * FloatFloatDimension, otherwise returns
     * <tt>false</tt>.
     *
     * @param o the object to check against
     * @return <tt>true</tt> if the two FloatFloatDimensions are equal
     */
    public boolean equals(Object o) {
        if (o instanceof FloatDimension) {
            FloatDimension d = (FloatDimension) o;
            return d.width == this.width && d.height == this.height;
        } else {
            return false;
        }
    }

    /**
     * Creates a new object of the same class as this object.
     *
     * @return a clone of this instance.
     */
    public Object clone() {
        return new FloatDimension(this);
    }

    /**
     * Returns a String representation of this FloatDimension.
     *
     * @return a String representing this FloatDimension.
     */
    public String toString() {
        return super.toString() + "[" + width + ", " + height + "]";
    }
}